/*
 * Copyright 2009 Biz-e (info@biz-e.nl)
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package nl.biz_e.gwtappengine.lib.client.widgets;

import java.util.List;

import nl.biz_e.appengine.lib.shared.objectify.IEntity;
import nl.biz_e.gwt.baselib.ui.client.widgets.DataButtonBar;
import nl.biz_e.gwt.baselib.ui.client.widgets.DataButtonBar.DataButtonBarListener;

import com.google.gwt.user.client.ui.VerticalPanel;

/**
 * TODO Finish this
 * 
 * @author Joost A. Bloemsma
 * @param <M>
 */
public class MasterDetail<M extends IEntity> extends VerticalPanel implements
        DataButtonBarListener {
    private final DataGrid grid;
    private final DataDetailPanel detail;
    private List<M> data;

    /**
     * Constructs a new MasterDetail instance
     * 
     * @param grid
     * @param detail
     */
    public MasterDetail(DataGrid grid, DataDetailPanel detail) {
        super();
        this.grid = grid;
        this.detail = detail;
        this.add(grid);
        this.add(detail);
        this.add(new DataButtonBar(this));
    }

    /**
     * Set the list containing the modelas
     * 
     * @param data
     */
    public void setData(List<M> data) {
        this.data = data;
    }

    /**
     * @return the data
     */
    public List<M> getData() {
        return data;
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public void onDelete() {
        // TODO Auto-generated method stub

    }

    /**
     * {@inheritDoc}
     */
    @Override
    public void onNew() {
        // TODO Auto-generated method stub

    }

    /**
     * {@inheritDoc}
     */
    @Override
    public void onSave() {
        // TODO Auto-generated method stub

    }

    /**
     * @return the grid
     */
    protected DataGrid getGrid() {
        return grid;
    }

    /**
     * @return the detail
     */
    protected DataDetailPanel getDetail() {
        return detail;
    }

}
